<template>
	<view>
		<u-cell-group>
			<u-cell title=" ">
				<view style="height: 80rpx;width: 100%;display: flex;align-items: center;" slot="value" class="u-slot-value">
					<text style="margin-right: 10rpx;">旧的密码:</text>
				 <u--input
				    placeholder="请输入内容"
					border="none"
				    v-model="user.oldpassword"
				  ></u--input>
				</view>
			</u-cell>
			<u-cell title=" ">
				<view style="height: 80rpx;width: 100%;display: flex;align-items: center;" slot="value" class="u-slot-value">
					<text style="margin-right: 10rpx;">新的密码:</text>
				 <u--input
				    placeholder="请输入内容"
					border="none"
				    v-model="user.newpassword"
				  ></u--input>
				</view>
			</u-cell>
			<u-cell title=" ">
				<view style="height: 80rpx;width: 100%;display: flex;align-items: center;" slot="value" class="u-slot-value">
					<text style="margin-right: 10rpx;">确认密码:</text>
				 <u--input
				    placeholder="请输入内容"
					border="none"
				    v-model="user.renewpassword"
				  ></u--input>
				</view>
			</u-cell>
		</u-cell-group>
		<view class="" style="position: fixed;left: 0;bottom: 20rpx;width: 100%;">
			<view class="" style="margin: 0 20rpx;">
				<u-button type="primary" @click="submit" text="提交"></u-button>
			</view>
		
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {
					oldpassword: '',
					newpassword: ''
				},
			}
		},
		onLoad() {
			
		},
		methods: {
			
			submit(){
				if(!this.user.oldpassword || !this.user.newpassword || !this.user.renewpassword){
					return this.$u.toast('请全部输入完整');
				}
				this.$api.user.changepwd(this.user).then(res => {
					if (res.code == 1) {
						this.$u.toast('修改成功');
						uni.removeStorageSync('lifeData');
						setTimeout(() => {
							uni.redirectTo({
								url: '/pages/login/login'
							})
						},500)
						
					}
				
				})
			},
			
		}
	}
</script>

<style>

</style>
